// mircoApp/manualOrder/components/textAreaPopup/textAreaPopup.js
const app = getApp();
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    show: {
      type: Boolean,
      default: false
    },
    popupObj: {
      type: Object,
      default: {
        title: "",
        api: ""
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    textArea: ""
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onClickLeft() {
      this.triggerEvent('childPost', false)
    },
    onClickRight() {
      let json = this.data.popupObj.params;
      json.remark = this.data.textArea;
      this.textAreaSubmitPost(json);
    },
    textAreaSubmitPost(json) {
      let urlStr = app.getNetAddresss(this.data.popupObj.api);
      app._postNetWork({
        url: urlStr,
        data: json,
        success: (resdata) => {
          let res = resdata.data
          if (res.result == 1) {
            app.tips(res.msg)
            this.triggerEvent('subPost', false)
          } else {
            app.tips(res.msg)
          }
        },
        fail: function (res) {
          console.log(res);
        }
      });
    }
  }
})